<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePatentAppliesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('patent_applies', function (Blueprint $table) {
            $table->id();
            $table->string('uuid', 32)->unique()->comment('编号');
            $table->string('patent_sn', 20)->nullable()->comment('申请号');
            $table->string('patent_name', 150)->comment('专利名称');
            $table->date('apply_date')->nullable()->comment('申请日');
            //全体发明人
            $table->string('inventor', 150)->nullable()->comment('发明人');
            //专利负责人 第一发明人
            $table->string('charge_person', 20)->nullable()->comment('专利负责人/第一发明人');
            $table->string('company', 100)->nullable()->comment('所属单位');
            $table->string('contact_person', 20)->nullable()->comment('联系人');
            $table->string('phone', 20)->nullable()->comment('联系电话');

            $table->string('applicant', 150)->nullable()->comment('申请人');
            $table->string('patent_person', 50)->nullable()->comment('专利权人');
            $table->string('other_applicant', 100)->nullable()->comment('其它申请人');

            $table->smallInteger('patent_type_id')->comment('专利类型');
            $table->string('country', 50)->nullable()->comment('国家');
            $table->smallInteger('apply_channel')->default(0)->comment('申请途径1巴黎公约2PCT途径');
            $table->string('other_patent_sn', 20)->nullable()->comment('其他申请号');

            $table->smallInteger('patent_attr')->default(0)->comment('专利属性');

            $table->smallInteger('te_source')->default(0)->comment('技术来源');
            $table->string('te_source_remark')->nullable()->comment('技术来源备注');

            $table->smallInteger('te_field')->default(0)->comment('技术领域');
            $table->string('te_field_remark')->nullable()->comment('技术领域备注');

            $table->smallInteger('te_maturity')->nullable()->comment('技术成熟度');
            $table->string('te_maturity_remark')->nullable()->comment('技术成熟度备注');

            $table->smallInteger('ptm')->default(0)->comment('拟采取转化方式');
            $table->string('ptm_remark')->nullable()->comment('拟采取转化方式备注');

            $table->smallInteger('novelty')->default(0)->comment('新颖性');
            $table->smallInteger('creativity')->default(0)->comment('创造性');
            $table->smallInteger('practicality')->default(0)->comment('实用性');
            $table->smallInteger('prospect')->default(0)->comment('应用前景');
            //Core technology scheme
            $table->text('cts')->nullable()->comment('核心技术方案');

            $table->tinyInteger('ownership_divide')->default(0)->comment('所有权分割');

            $table->string('file')->nullable()->comment('技术交底书');
            $table->string('report')->nullable()->comment('评估报告');
            $table->string('table_file')->nullable()->comment('评估表');

            $table->tinyInteger('status')->default(0)->comment('状态1授权');
            $table->tinyInteger('review_status')->default(0)->comment('管理端审核状态');
            $table->tinyInteger('dept_review_status')->default(0)->comment('部门审核审状态');
            $table->text('dept_review_remark')->nullable()->comment('科室审批意见');
            $table->string('review_remark')->nullable()->comment('审核备注');

            $table->integer('user_id')->comment('申请人ID');
            $table->integer('department_id')->default(0)->comment('部门ID');

            $table->tinyInteger('is_agent')->default(0);
            $table->integer('agency_id')->default(0);
            $table->timestamps();

            $table->index('user_id');
            $table->index('department_id');
            $table->index('patent_sn');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('patent_applies');
    }
}
